package com.woniu.util;

import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author 李松桦
 * @data 2023/3/15 12:48
 */

public class DateUtil {
   public static String getDateFormat(){
       Date date = new Date();
       date.setDate(1);
       date.setHours(0);
       date.setMinutes(0);
       date.setSeconds(0);

       SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
       String strDate = simpleDateFormat.format(date);

       System.out.println(date);
       return strDate;
   }

   public static Date getNextDate(){
       Date date1 = new Date();
       date1.setMonth(date1.getMonth()+1);
       date1.setDate(1);
       date1.setHours(0);
       date1.setMinutes(0);
       date1.setSeconds(0);
       System.out.println(date1);
       return date1;
   }

    public static Date getLastDate(){
        Date date2 =   new Date();
        date2.setMonth(date2.getMonth()-1);
        date2.setDate(1);
        date2.setHours(0);
        date2.setMinutes(0);
        date2.setSeconds(0);
        System.out.println(date2);
        return date2;
    }

    public static  Date getNowDate(){
       Date nowDate = new Date();
       return nowDate;
    }

    public static Date getDate(){
        Date date = new Date();
        date.setDate(1);
        date.setHours(0);
        date.setMinutes(0);
        date.setSeconds(0);
        return date;
    }
}
